package org.gitos.cloud.domain.tcp;

import org.gitos.cloud.util.ByteUtil;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by shizhengchu on 16/1/13.
 * 数据包序号或应答序号
 */
public class Sequeue extends Field {
    public static final int LENGTH = 4;
    public static AtomicInteger base = new AtomicInteger(0);

    protected void initBaseValue() {
        this.setValue(ByteUtil.int2Bytes(base.incrementAndGet()));
    }

    public Sequeue() {
        init(LENGTH);
        initBaseValue();
    }

    public static Sequeue instance() {
        Sequeue queue = new Sequeue();
        return queue;
    }

    public static Sequeue instance(byte[] id) {
        Sequeue queue = new Sequeue();
        queue.setValue(id);
        return queue;
    }
}
